/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-03-31
 * Time: 15:54
 */
public class Student {
    private String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }


    @Override
    //Object类中的toString()方法实现
    //默认实现：类名@十六进制哈希码，只有重新重写才能获取对象信息，不重写就默认实现下面这串代码
    public String toString() {
        return getClass().getName() + "@" + Integer.toHexString(hashCode());
    }

    public static void main(String[] args) {
        Student student = new Student("liming", 25);
        System.out.println(student); // 默认调用 toString()
        //输出：Student@4eec7777
    }
}
